package com.ruoyi.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.framework.utils.StringUtil;
import com.ruoyi.system.domain.BModel;
import com.ruoyi.system.domain.request.ModelRequest;
import com.ruoyi.system.domain.vo.BCaseVo;
import com.ruoyi.system.domain.vo.BModelVo;
import com.ruoyi.system.service.BModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/model")
public class ModelController extends BaseController {

    @Autowired
    BModelService modelService;

    /**
     * 获模型列表
     */
    @GetMapping("/list")
    public TableDataInfo getList(ModelRequest request){
        startPage();
        String name = request.getName();
        List<BModelVo> list = modelService.getList(name);
        return getDataTable(list);
    }

    /**
     * 获模型列表
     */
    @GetMapping("/hotList")
    public TableDataInfo getHotList(){
        BModel bModel = new BModel();
        bModel.setIsHot("1");
        List<BModelVo> list = modelService.selectModelList(bModel);
        return getDataTable(list);
    }

    /**
     * 根据指南Id获取详细信息
     */
    @GetMapping(value = "/{modelId}")
    public AjaxResult getInfo(@PathVariable Long modelId) {
        BModelVo modelVo = modelService.selectModelById(modelId);
        return success(modelVo);
    }
}
